<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <?php
        require_once 'conn.php';
        $id = $_POST['id'];
        $name = $_POST['name'];
        $password = $_POST['password'];
        if($_POST['sex'] == '男'){
            $sex = '男';
        }
        else if($_POST['sex'] == '女'){
            $sex = '女';
        }
        else {
            $sex = '保密';
        }
        $age = $_POST['age'];
        $hobby = $_POST['hobby'];
        $detail = $_POST['detail'];
        
        // 执行语句
        mysqli_query($con,"UPDATE user SET name='$name',password='$password',sex='$sex',age='$age',hobby='$hobby',detail='$detail' WHERE id = $id");
        $rows = mysqli_affected_rows($con);
        if($rows >= 1){
            echo '修改成功';
            header('location:list.php');
        }
        else {
            echo '修改失败';
        }
    ?>
</body>
</html>